import axios from 'axios'

export default function doPost (obj, cb) {
  console.log(obj)
  let action = obj.action
  let parameter = obj.parameter
  let Configuration = obj.Configuration
  let condition = ''
  let url
  if(parameter) {
    for (var k in parameter) {
      let value = parameter[k] !== undefined ? parameter[k] : ''
      condition += '&' + k + '=' + encodeURIComponent(value)
    }
    url = `http://127.0.0.1:3000/${action}?${condition}`
  }else{
    url = `http://127.0.0.1:3000/${action}`
  }
  console.log(url)
  axios({
    url: url,
    method: 'get',
  })
  .then((resp) => {
    cb(resp.data)
  })
}
